package dome1;

import java.util.Comparator;

class Test1 {
    public static void main(String[] args) {
        int a =10;
        int b= 20;
        System.out.println(a>b);
    }
}
class Stundent implements Comparable<Stundent> {
    public String name;
    public int age;

    public Stundent(String name, int age) {
        this.name = name;
        this.age = age;
    }
    @Override
    public String toString() {
        return "Stundent{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Stundent o) {
      /*  if(this.age>o.age){
            return 1;
        }else if(this.age == o.age){
            return  0;
        }else {
            return -1;
        }*/
        return this.age - o.age;
    }

}
    class AgeComparator implements Comparator<Stundent> {

        @Override
        public int compare(Stundent o1, Stundent o2) {
            return o1.age - o2.age;
        }

    }



public  class Test{
    public static void main(String[] args) {
        Stundent student1 = new Stundent("zhangsan",12);
        Stundent student2 = new Stundent("lisi",13);

        System.out.println(student1.compareTo(student2));
        AgeComparator ageComparator = new AgeComparator();
        System.out.println(ageComparator.compare(student1,student2));


    }
}